package chp12.test3;

public class Loan {

    public void loan(double loan,int yearchoice){
        //总利息 = 贷款金额 * 利率
        //每月还款 = (贷款金额 + 总利息) / 贷款年限的月份数
        double rate = 0; //利率
        int year = 0; //贷款年限
        if(yearchoice == 1){
            rate = 6.03 / 100;
            year = 3;
        }else if(yearchoice == 2){
            rate = 6.12 / 100;
            year = 5;
        }else if(yearchoice == 3){
            rate = 6.39 / 100;
            year = 20;
        }

        double zonglixi = loan * rate;
        double moneyMonth = (loan + zonglixi) / (year*12);
        System.out.println("月供为:"+moneyMonth);
    }
}
